extends EntryTrigger


class_name ItemTrigger
"""
监听ItemContainer事件触发变更
"""


@export var item_container: ItemContainer = null


func __check_exports() -> Dictionary:
    return IComponent.merge({
        "item_container": IComponent.find_up_nearby.bind(self, func(x): return x is ItemContainer, item_container),
    }, super.__check_exports())

func __init_hooks() -> Dictionary:
    return IComponent.merge({
        item_container.event_append_component: on_item_append,
        item_container.event_remove_component: on_item_remove,
    }, super.__init_hooks())

func on_item_append(cmpt: ItemContainer, node: Node) -> void:
    __on_event_enter()

func on_item_remove(cmpt: ItemContainer, node: Node) -> void:
    __on_event_exit()
